﻿@model SrBBSPro.Entities.HolidayCount
@{
    ViewBag.Title = "休假一览";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
<div class="main layui-clear">
    <div class="wrap">
        <div class="layui-form layui-form-pane">
            <fieldset class="layui-elem-field">
                <legend>检索条件</legend>
                <div class="layui-field-box">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">部门:</label>
                            <div class="layui-input-block">
                                <select id="Depart" name="Depart">
                                    <option value="">请选择</option>
                                    <option value="1">一部</option>
                                    <option value="2">二部</option>
                                    <option value="3">三部</option>
                                    <option value="4">四部</option>
                                    <option value="5">五部</option>
                                    <option value="6">六部</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">社员姓名</label>
                            <div class="layui-input-block">
                                <input class="layui-input" id="staffName" />
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" style="float:right">
                        <a href="#" class="layui-btn layui-btn-normal" id="btnSearch">
                            <i class="layui-icon layui-icon-search"></i>检索
                        </a>
                    </div>
                </div>
            </fieldset>
        </div>
        <table id="holiday" lay-filter="holiday"></table>
        <script type="text/html" id="toolbar">
            <b>@Model.Title - 社员休假信息一览</b>
        </script>
        <script type="text/html" id="StaffNoTpl">
            <a href="#" class="layui-table-link" lay-event="edit">{{d.No || ''}}</a>
        </script>
    </div>
</div>

@section scripts{
    <script>
        layui.use(['table','jquery'], function () {
            var $ = layui.jquery;
            var table = layui.table;
            var hid = '@Model.Id';
            table.render({
                elem: '#holiday'
                , height: 500
                , title: '休假列表'
                , url: '/Count/NoteList?hid=' + hid
                , autoSort: false
                , page: {}
                , limits: [10]
                , toolbar: '#toolbar'
                , defaultToolbar: ['filter', 'exports', 'print']
                , cols: [[
                    { type: 'numbers' }
                    , { field: 'No', title: '工号', width: 100, templet: '#StaffNoTpl' }
                    , { field: 'StaffName', title: '姓名', width: 100 }
                    , { field: 'Depart', title: '所属部门', width: 100,hide :true }
                    , { field: 'DepartName', title: '所属部门', width: 100 }
                    , { field: 'StartDate', title: '开始时间', width: 120 }
                    , { field: 'EndDate', title: '结束时间', width: 120 }
                    , { field: 'Days', title: '休假天数', width: 200, templet: '<span>{{ d.Days }} 天</span>' }
                ]]
            });

            table.on('tool(holiday)', function (obj) {
                if (obj.event === 'edit') {
                    var data = obj.data;
                    redirect('Count', 'Detail', hid,data.No);                  
                }
            });

            $("#btnSearch").click(function () {
                var Depart = $("#Depart").val();
                var name = $("#staffName").val();
                table.reload('holiday', {
                    page: { curr: 1 }
                    , url: '/Count/NoteList?Depart=' + Depart + "&hid=" + hid + "&staffName=" + name
                });
            });
        });
    </script>
}